<template>
  <div>
    <!-- 底部部分 -->
    <footer class="footer" >
      <span class="todo-count"><strong>{{leftCount}}</strong>剩余</span>
      <ul class="filters" @click="$emit('changeAll',type)">
        <li>
          <a 
          :class="{selected : type === 'all'}"
          @click.prevent="type = 'all'"
          href="#/">全部</a>
        </li>
        <li>
          <a 
          :class="{selected : type === 'active'}"
          @click.prevent="type = 'active'"
          href="#/active">进行中</a>
        </li>
        <li>
          <a 
          :class="{selected : type === 'completed'}"
          @click.prevent="type = 'completed'"
          href="#/completed">已完成</a>
        </li>
      </ul>
      <button class="clear-completed" @click="clearDone" v-show="showClear">清除已完成</button>
    </footer>
  </div>
</template>

<script>
export default {
  name: 'TodoFooter',
  props : {
    list : {
      type:Array,
      required : true
    }
  },
  data() {
    return {
      type: ''
    };
  },

  methods: {
   clearDone() {
     this.$emit('showClear')
       
    }
  },
  computed: {
    leftCount() {
      return this.list.length
    },
    showClear() {
      return this.list.some(item => item.isDone)
    }
   
  }
};
</script>

<style lang="scss" scoped>

</style>